package soar.template.springboot.service.hello.configuration.mvc;

import javax.annotation.Resource;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

//<mvc:interceptors>
//<mvc:interceptor>
//  <mvc:mapping path="/app/*.api"/>
//  <bean class="com.hupu.user.interceptor.AuthorizationInterceptor" ></bean>
//</mvc:interceptor>
//<!-- 拦截器，用于风控 -->
//<mvc:interceptor>
//  <mvc:mapping path="/**"/>
//  <mvc:exclude-mapping path="/**/*.css" />
//  <mvc:exclude-mapping path="/**/*.js" />
//  <mvc:exclude-mapping path="/**/*.png" />
//  <mvc:exclude-mapping path="/**/*.jpg" />
//  <mvc:exclude-mapping path="/**/*.gif" />
//  <mvc:exclude-mapping path="/**/*.app"/>
//  <bean class="com.hupu.user.interceptor.RiskControlInterceptor"></bean>
//</mvc:interceptor>
//</mvc:interceptors>

@Configuration
class MyWebMvcConfiguration extends WebMvcConfigurerAdapter
{
    // @Bean
    // public SecurityInterceptor getSecurityInterceptor()
    // {
    // SecurityInterceptor interceptor = new SecurityInterceptor();
    // return interceptor;
    // }

    @Resource
    private SecurityInterceptor securityInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry)
    {
        // registry.addInterceptor(getSecurityInterceptor())
        registry.addInterceptor(securityInterceptor).addPathPatterns("/**")
                .excludePathPatterns("/**/*.css")
                .excludePathPatterns("/**/*.js");
    }

}
